package org.gbif.crawler.console.action;

import java.io.IOException;
import java.util.Properties;

import com.google.inject.AbstractModule;
import com.google.inject.name.Names;

/**
 * A Guice module that loads Properties from the application.properties file and binds them as named properties.
 * 
 * @author kbraak
 */
public class ApplicationPropertiesModule extends AbstractModule {

  @Override
  protected void configure() {
    // bind the application properties
    try {
      Properties properties = new Properties();
      properties.load(this.getClass().getResourceAsStream("/application.properties"));
      Names.bindProperties(binder(), properties);
    } catch (IOException e) {
      throw new IllegalArgumentException("Unable to read application.properties", e);
    }
  }
}
